package com.backend.controller;

import com.backend.entity.Result;
import com.backend.entity.entity.Users;
import com.backend.mapper.UserMapper;
import com.backend.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

/**
 * 作者:xuSen
 * 日期2025/7/19 10:44
 */
@RestController
@RequestMapping("/api/user")
@Tag(name = "普通用户模块接口")
public class UserController {
    @Autowired
    private UserService userService;
    @PostMapping("commit")
    @Operation(summary = "用户提交工单")
    public Result commit(@RequestParam("user_id") int userid, @RequestParam("description") String description, @RequestParam("contact_info") String contactinfo, @RequestParam("device_code") String device_code ) {
        return userService.commit(userid,description,contactinfo,device_code);
    }
    @GetMapping("/GetAllOrderByUserId")
    @Operation(summary = "查看某用户的所有工单")
    public Result getAllOrderByUserId(@RequestParam("user_id") Integer userId) {
        return userService.getAllOrderByUserId(userId);
    }
    @PostMapping ("/Comment")
    @Operation(summary = "评价某工单")
    public Result Comment(@RequestParam("user_id") int userid, @RequestParam("Order_id") int orderid ,@RequestParam String feedback,@RequestParam int rating) {
        return userService.Comment(userid,orderid,feedback,rating);
    }
}
